<template>
  <div class="div1">
    <el-row>
      <el-col style="background-color: #ffffff;padding: 20px 0px 20px 0">
        <el-form label-width="100px" style="width:80%;">
          <el-form-item label="上传安装包:">
            <el-upload class="upload-demo"
                       drag
                       multiple
                       :auto-upload="false"
                       :on-change="onChange">
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            </el-upload>
          </el-form-item>
          <el-form-item style="text-align: center">
            <el-button type="primary" @click="onSubmit">提交</el-button>
            <el-button type="danger" @click="cancel">取消</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {addFDPD} from "@/api/operations-center/package";
export default {
  name: "packageAdd",
  data() {
    return {
      file: [],
      // fdpd: [],
    }
  },
  methods: {
    onChange(file){
      this.file = file;
    },
    onSubmit(){
      let formData = new FormData
      formData.append('file',this.file.raw)
      // formData.append('fdpd',this.fdpd)

      console.log(formData.get('file'));
      addFDPD(formData).then(res => {
        console.log(res);
        if (res.code == 200) {

        }
      })
    },
    cancel() {
      this.$router.go(-1)
    }
  }
}
</script>

<style lang="scss" scoped>
.div1 {
  padding-left: 30%;
  padding-right: 30%;
}
</style>
